package com.hsxc.cdz.monitor.bean.second;

/**
 * 故障信息
 * @author llw
 *
 */
public class Fault {
	private byte[] bit ; //故障信息
	/*
	 *  bit0     急停故障
	 *  bit1     电表故障
	 *  bit2     接触器故障
	 *  bit3     读卡器故障
	 *  bit4     内部过温故障
	 *  bit5     连接器故障
	 *  bit6     绝缘故障
	 *  bit7     其他
	 */
	public static final int length = 8;
	public static final String NOMAL = "00";   //正常
	public static final String ERR_STOP = "01";    //急停故障
	public static final String ERR_AMETER = "02";  //电表故障
	public static final String ERR_CONTACTOR = "03"; //接触器器故障
	public static final String ERR_CARDREADER = "04"; //读卡器故障
	public static final String ERR_HOT = "05";  //内部高温故障
	public static final String ERR_CONNECTOR = "06"; //连接器故障
	public static final String ERR_INSULATION = "07"; //绝缘故障
	public static final String ERR_OTHER = "0A"; //其他;
	
	public Fault(){
		bit = new byte[length];
	}
	public Fault(byte data){
		this();
		for(int i=0;i<length;i++){
			bit[i] = (byte)(0x01&(data>>i));
		}
	}
	
	public String getFault(){
		for(int i=0;i<length;i++){
			if(bit[i]==1){
				return "0"+(i+1);
			}
		}
		return NOMAL;
	}
}
